package com.bayern.entity;

/**
 * 缓存对象基类，所以缓存对象都要继承这个类
 * @author linling
 *
 */
public abstract class CacheObject<K, V> implements Comparable<CacheObject<K, V>>
{
	protected Integer number;
	protected Entry<K, V> entry;

	public CacheObject(Entry<K, V> entry)
	{
		super();
		this.entry = entry;
	}
	
	public CacheObject(Integer number, Entry<K, V> entry)
	{
		super();
		this.number = number;
		this.entry = entry;
	}
	
	public Integer getNumber()
	{
		return number;
	}

	public void setNumber(Integer number)
	{
		this.number = number;
	}

	public Entry<K, V> getEntry()
	{
		return entry;
	}

	public void setEntry(Entry<K, V> entry)
	{
		this.entry = entry;
	}

	public V replace(K key, V value)
	{
		V oldValue = entry.getValue();
		entry.setValue(value);
		return oldValue;
	}
	
}
